package cn.jbolt.common.handler;

import com.jfinal.handler.Handler;
import com.jfinal.kit.StrKit;

import cn.jbolt.common.base.DecoderRequest;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 1：演示跳过 url， Handler 中断
 * 2：演示 isHandled 变量操作，结合 AOP 多Handler 交互
 */
public class DecoderHandler extends Handler {
	
	public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
            String q=request.getParameter("q");
            //排除静态资源请求，并且请求中包含密文参数q
            if(target.indexOf(".")== -1 && StrKit.notBlank(q)) {
                //替换controller的request对象，实现对加密参数进行解密，使参数对controller透明化
                request=new DecoderRequest(request);
            }
        //继续走下一个handler
          next.handle(target, request, response, isHandled);
		  //isHandled[0] = true;
	}
}


